#ifndef __AS_LABEL__H__
#define __AS_LABEL__H__

#include "ASControl.h"
#include "ASImage.h"

typedef enum
{
    AS_LABEL_TEXT_LEFT      = 0x000001,
    AS_LABEL_TEXT_H_CENTER  = 0x000002,
    AS_LABEL_TEXT_RIGHT     = 0x000004,
    AS_LABEL_TEXT_TOP       = 0x000008,
    AS_LABEL_TEXT_V_CENTER  = 0x000010,
    AS_LABEL_TEXT_BOTTOM    = 0x000020,

    AS_LABEL_TEXT_CENTER    = AS_LABEL_TEXT_H_CENTER | AS_LABEL_TEXT_V_CENTER,
    AS_LABEL_TEXT_LEFT_TOP  = AS_LABEL_TEXT_LEFT | AS_LABEL_TEXT_TOP,
    AS_LABEL_TEXT_RIGHT_TOP = AS_LABEL_TEXT_RIGHT | AS_LABEL_TEXT_TOP,
    AS_LABEL_TEXT_LEFT_BOTTOM = AS_LABEL_TEXT_LEFT | AS_LABEL_TEXT_BOTTOM,
    AS_LABEL_TEXT_RIGHT_BOTTOM = AS_LABEL_TEXT_RIGHT | AS_LABEL_TEXT_BOTTOM,

    /*add before this line*/
    AS_LABEL_TEXT_LAYOUT_MAX
} as_label_text_layout;

struct _as_text_pos_info;
typedef struct _as_text_pos_info as_text_pos_info;
struct _as_text_pos_info
{
    ASWCHAR* start_p;
    ASINT cnts;
    //as_rect area;//when text_y_off = 0
};

typedef struct
{
    /* base */
    as_control base;

    /* attributes */
    ASWSTR text;
    ASINT text_x_off, text_y_off; //relative to base.area
    ASUINT text_color;
    as_image* bg_img;
    ASUINT bg_color;
    ASUINT bg_frame_color;
    as_label_text_layout layout;
    ASINT if_bg_hidden;
    ASINT if_multiline;//internal
    as_text_pos_info* text_pos_info;
    ASINT total_height;
    ASINT single_line_height;
    ASBOOL if_small;

    /* methods */

    /*
     *	[description] change the label text
     *  [param] ctrl_p : which you want to change text
     *  [param] text : target text
     *  [return] as_ret : AS_OK or else
     */
    as_ret (*change_text)(as_control* ctrl_p, ASWSTR text);

    /*
     *	[description] set the color of label text
     *  [param] ctrl_p : which you want to change attribute
     *  [param] color : data type as 0Xrrggbb,we will translate it into vm color internal
     *  [return] as_ret : AS_OK and otherwise
     */
    as_ret (*set_text_color)(as_control* ctrl_p, ASUINT color);

    /*
     *	[description] get the color of label text
     *  [param] ctrl_p : which you want to change attribute
     *  [param] color_p : for store color,data type as 0Xrrggbb,we will translate it into vm color internal
     *  [return] as_ret : AS_OK and otherwise
     */
    as_ret (*get_text_color)(as_control* ctrl_p, ASUINT* color_p);

    /*
     *	[description] set the background color of label text
     *  [param] ctrl_p : which you want to change attribute
     *  [param] color : data type as 0Xrrggbb,we will translate it into vm color internal
     *  [return] as_ret : AS_OK and otherwise
     */
    as_ret (*set_bg_color)(as_control* ctrl_p, ASUINT color);

    /*
     *	[description] set the background frame color of label text
     *  [param] ctrl_p : which you want to change attribute
     *  [param] color : data type as 0Xrrggbb,we will translate it into vm color internal
     *  [return] as_ret : AS_OK and otherwise
     */
    as_ret (*set_bg_frame_color)(as_control* ctrl_p, ASUINT color);

    /*
     *	[description] set the layout of text in label
     *  [param] ctrl_p : which you want to change attribute
     *  [param] layout : enum as_label_text_layout
     *  [return] as_ret : AS_OK and otherwise
     */
    as_ret (*set_layout)(as_control* ctrl_p, as_label_text_layout layout);

    /* use the method [set_layout] in our suggestion. */
    as_ret (*set_text_offset)(as_control* ctrl_p, ASINT16 x_off, ASINT16 y_off);

    as_ret (*set_bg_hidden)(as_control* ctrl_p, ASINT if_hidden);

    as_ret (*set_bg_img)(as_control* ctrl_p, as_image_src_type type, ASWSTR path);

    ASINT (*get_total_height)(as_control* ctrl_p);

    as_ret (*set_if_small)(as_control* ctrl_p, ASBOOL if_small);
} as_label;

/*
 *	[description] create a label control
 *  [param] area : area of this control
 *  [param] text : text of this control
 *  [return] as_label* : if NULL , means create failed.
 *                       else return the pointer of label.
 */
as_label* as_ctrl_label_create(as_rect area, ASWSTR text);

/*
 *	[description] destroy a existed label
 *  [param] ctrl_label_p : pointer of label control
 *  [return] as_ret : AS_OK means destroy successful,else are abnormal.
 */
as_ret as_ctrl_label_destroy(as_label* ctrl_label_p);


#endif//__AS_LABEL__H__